package com.itcv.mybatis.demo;

import com.itcv.mybatis.demo.dao.MatchRulesMapper;
import com.itcv.mybatis.demo.model.MatchRules;
import com.itcv.mybatis.demo.util.ProxyUtils;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Map;

public class Demo {


    public static void main(String[] args) {
        try {

            System.out.println(Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC);//1033
            String resource = "mybatis-config.xml";
            InputStream inputStream = Resources.getResourceAsStream(resource);
            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
            SqlSession sqlSession = sqlSessionFactory.openSession();
            MatchRulesMapper mapper = sqlSession.getMapper(MatchRulesMapper.class);
         //   ProxyUtils.generateClassFile(mapper.getClass(),"MatchRulesProxy");
         //   Integer maxNum = mapper.maxSortNum();
            List<MatchRules> m = mapper.findMapByParam("测");
            System.out.println(m.get(0).getRuleName());
            System.out.println(m.size());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
